<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">

<title>class AboutYou::SDK::Model::Product - RDoc Documentation</title>

<link href="../../../fonts.css" rel="stylesheet">
<link href="../../../rdoc.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../../";
</script>

<script src="../../../js/jquery.js"></script>
<script src="../../../js/navigation.js"></script>
<script src="../../../js/search_index.js"></script>
<script src="../../../js/search.js"></script>
<script src="../../../js/searcher.js"></script>
<script src="../../../js/darkfish.js"></script>


<body id="top" role="document" class="class">
<nav role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2>
    <a href="../../../index.html" rel="home">Home</a>
  </h2>

  <div id="table-of-contents-navigation">
    <a href="../../../table_of_contents.html#pages">Pages</a>
    <a href="../../../table_of_contents.html#classes">Classes</a>
    <a href="../../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  

  <div id="class-metadata">
    
    <div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  
  <p class="link">Object
  
</div>

    <div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
  
  
    <li><a class="include" href="AbstractModel.html">AboutYou::SDK::Model::AbstractModel</a>
  
  
  </ul>
</div>

    
    <!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    
    <li ><a href="#method-c-create_from_json">::create_from_json</a>
    
    <li ><a href="#method-i-brand">#brand</a>
    
    <li ><a href="#method-i-categories">#categories</a>
    
    <li ><a href="#method-i-category">#category</a>
    
    <li ><a href="#method-i-category_with_longest_active_path">#category_with_longest_active_path</a>
    
    <li ><a href="#method-i-excluded_facet_groups">#excluded_facet_groups</a>
    
    <li ><a href="#method-i-facet_group_set">#facet_group_set</a>
    
    <li ><a href="#method-i-generate_facet_group_set">#generate_facet_group_set</a>
    
    <li ><a href="#method-i-group_facets">#group_facets</a>
    
    <li ><a href="#method-i-leaf_category_ids">#leaf_category_ids</a>
    
    <li ><a href="#method-i-parse_attributes_json">#parse_attributes_json</a>
    
    <li ><a href="#method-i-parse_category_id_paths">#parse_category_id_paths</a>
    
    <li ><a href="#method-i-parse_facet_ids">#parse_facet_ids</a>
    
    <li ><a href="#method-i-parse_facet_ids_in_attributes_merged">#parse_facet_ids_in_attributes_merged</a>
    
    <li ><a href="#method-i-parse_facet_ids_in_brand">#parse_facet_ids_in_brand</a>
    
    <li ><a href="#method-i-parse_facet_ids_in_variants">#parse_facet_ids_in_variants</a>
    
    <li ><a href="#method-i-parse_styles">#parse_styles</a>
    
    <li ><a href="#method-i-parse_variants">#parse_variants</a>
    
    <li ><a href="#method-i-root_category_ids">#root_category_ids</a>
    
    <li ><a href="#method-i-selectable_facet_groups">#selectable_facet_groups</a>
    
    <li ><a href="#method-i-variant_by_facet">#variant_by_facet</a>
    
    <li ><a href="#method-i-variant_by_id">#variant_by_id</a>
    
    <li ><a href="#method-i-variants_by_ean">#variants_by_ean</a>
    
    <li ><a href="#method-i-variants_by_facet_id">#variants_by_facet_id</a>
    
  </ul>
</div>

  </div>
</nav>

<main role="main" aria-labelledby="class-AboutYou::SDK::Model::Product">
  <h1 id="class-AboutYou::SDK::Model::Product" class="class">
    class AboutYou::SDK::Model::Product
  </h1>

  <section class="description">
    
<p>This class represents an product model</p>

  </section>

  
  
  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    
    <section class="attribute-method-details" class="method-section">
      <header>
        <h3>Attributes</h3>
      </header>

      
      <div id="attribute-i-active_leaf_categories" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">active_leaf_categories</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>active leaf categories of the product</p>
        
        </div>
      </div>
      
      <div id="attribute-i-active_root_categories" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">active_root_categories</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>active root categories for the product</p>
        
        </div>
      </div>
      
      <div id="attribute-i-brand_id" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">brand_id</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>product brand id</p>
        
        </div>
      </div>
      
      <div id="attribute-i-category_id_paths" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">category_id_paths</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>category id paths of this product</p>
        
        </div>
      </div>
      
      <div id="attribute-i-default_image" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">default_image</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>product default image</p>
        
        </div>
      </div>
      
      <div id="attribute-i-default_variant" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">default_variant</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>product default variant</p>
        
        </div>
      </div>
      
      <div id="attribute-i-description_long" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">description_long</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>long description</p>
        
        </div>
      </div>
      
      <div id="attribute-i-description_short" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">description_short</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>short description</p>
        
        </div>
      </div>
      
      <div id="attribute-i-facet_groups" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">facet_groups</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>facet groups of product</p>
        
        </div>
      </div>
      
      <div id="attribute-i-facet_ids" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">facet_ids</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>facet ids of this product</p>
        
        </div>
      </div>
      
      <div id="attribute-i-factory" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">factory</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>instance of <a
href="../Factory/DefaultModelFactory.html">AboutYou::SDK::Factory::DefaultModelFactory</a></p>
        
        </div>
      </div>
      
      <div id="attribute-i-id" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">id</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>product id</p>
        
        </div>
      </div>
      
      <div id="attribute-i-inactive_variants" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">inactive_variants</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>inactive styles of product</p>
        
        </div>
      </div>
      
      <div id="attribute-i-is_active" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">is_active</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>product active or not</p>
        
        </div>
      </div>
      
      <div id="attribute-i-is_sale" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">is_sale</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>product in sale or not</p>
        
        </div>
      </div>
      
      <div id="attribute-i-leaf_categories" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">leaf_categories</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>leaf categories for product</p>
        
        </div>
      </div>
      
      <div id="attribute-i-max_price" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">max_price</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>product max price</p>
        
        </div>
      </div>
      
      <div id="attribute-i-max_savings" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">max_savings</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>product max savings</p>
        
        </div>
      </div>
      
      <div id="attribute-i-max_savings_percentage" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">max_savings_percentage</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>product max savings percentage</p>
        
        </div>
      </div>
      
      <div id="attribute-i-max_savings_price" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">max_savings_price</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>product max savings price</p>
        
        </div>
      </div>
      
      <div id="attribute-i-merchant_id" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">merchant_id</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>product merchant id</p>
        
        </div>
      </div>
      
      <div id="attribute-i-min_price" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">min_price</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>product min price</p>
        
        </div>
      </div>
      
      <div id="attribute-i-name" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">name</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>product name</p>
        
        </div>
      </div>
      
      <div id="attribute-i-root_categories" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">root_categories</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>root categories for product</p>
        
        </div>
      </div>
      
      <div id="attribute-i-selected_variant" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">selected_variant</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>product selected variant</p>
        
        </div>
      </div>
      
      <div id="attribute-i-styles" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">styles</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>styles of product</p>
        
        </div>
      </div>
      
      <div id="attribute-i-variants" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">variants</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>variants of product</p>
        
        </div>
      </div>
      
    </section>
    

    
     <section id="public-class-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Class Methods</h3>
       </header>

    
      <div id="method-c-create_from_json" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">create_from_json</span><span
            class="method-args">(json_object, factory, app_id)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method is used for creating an instance of this class by a
json_object.</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>json_object</code> -&gt; the json_object received from the api</p>
</li><li>
<p><code>factory</code> -&gt; instance of <a
href="../Factory/DefaultModelFactory.html">AboutYou::SDK::Factory::DefaultModelFactory</a></p>
</li><li>
<p><code>app_id</code> -&gt; app id of the product</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Product.html">AboutYou::SDK::Model::Product</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="create_from_json-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 75</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">create_from_json</span>(<span class="ruby-identifier">json_object</span>, <span class="ruby-identifier">factory</span>, <span class="ruby-identifier">app_id</span>)
  <span class="ruby-identifier">product</span> = <span class="ruby-identifier">new</span>

  <span class="ruby-comment"># these are required fields</span>
  <span class="ruby-identifier">fail</span> <span class="ruby-string">'MalformedJsonException!'</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'id'</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'name'</span>]

  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">factory</span> = <span class="ruby-identifier">factory</span>

  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">id</span>                     = <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'id'</span>]
  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">name</span>                   = <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'name'</span>]

  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">is_sale</span>                = <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'sale'</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'sale'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">false</span>
  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">description_short</span>      = <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'description_short'</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'description_short'</span>] <span class="ruby-operator">:</span> <span class="ruby-string">''</span>
  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">description_long</span>       = <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'description_long'</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'description_long'</span>] <span class="ruby-operator">:</span> <span class="ruby-string">''</span>
  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">is_active</span>              = <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'active'</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'active'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">true</span>
  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">brand_id</span>               = <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'brand_id'</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'brand_id'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">merchant_id</span>            = <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'merchant_id'</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'merchant_id'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>

  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">min_price</span>              = <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'min_price'</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'min_price'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">max_price</span>              = <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'max_price'</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'max_price'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">max_savings_price</span>      = <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'max_savings'</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'max_savings'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">max_savings_percentage</span> = <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'max_savings_percentage'</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'max_savings_percentage'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>

  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">default_image</span>          = <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'default_image'</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">factory</span>.<span class="ruby-identifier">create_image</span>(<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'default_image'</span>]) <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">default_variant</span>        = <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'default_variant'</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">factory</span>.<span class="ruby-identifier">create_variant</span>(<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'default_variant'</span>], <span class="ruby-keyword">self</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>

  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">variants</span>               = <span class="ruby-identifier">product</span>.<span class="ruby-identifier">parse_variants</span>(<span class="ruby-identifier">json_object</span>, <span class="ruby-identifier">factory</span>, <span class="ruby-identifier">product</span>)
  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">inactive_variants</span>      = <span class="ruby-identifier">product</span>.<span class="ruby-identifier">parse_variants</span>(<span class="ruby-identifier">json_object</span>, <span class="ruby-identifier">factory</span>, <span class="ruby-identifier">product</span>, <span class="ruby-string">'inactive_variants'</span>)
  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">styles</span>                 = <span class="ruby-identifier">product</span>.<span class="ruby-identifier">parse_styles</span>(<span class="ruby-identifier">json_object</span>, <span class="ruby-identifier">factory</span>)

  <span class="ruby-identifier">key</span>                            = <span class="ruby-string">'categories.'</span> <span class="ruby-operator">+</span> <span class="ruby-constant">String</span>(<span class="ruby-identifier">app_id</span>)
  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">category_id_paths</span>      = <span class="ruby-identifier">json_object</span>[<span class="ruby-identifier">key</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-identifier">key</span>] <span class="ruby-operator">:</span> []

  <span class="ruby-identifier">product</span>.<span class="ruby-identifier">facet_ids</span>              = <span class="ruby-identifier">product</span>.<span class="ruby-identifier">parse_facet_ids</span>(<span class="ruby-identifier">json_object</span>)

  <span class="ruby-identifier">product</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
    </section>
  
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Instance Methods</h3>
       </header>

    
      <div id="method-i-brand" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">brand</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Getter for the brand</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Facet.html">AboutYou::SDK::Model::Facet</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="brand-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 529</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">brand</span>
  <span class="ruby-identifier">facet_group_set</span>.<span class="ruby-identifier">facet</span>(
    <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">Facet</span><span class="ruby-operator">::</span><span class="ruby-constant">FACET_BRAND</span>,
    <span class="ruby-identifier">brand_id</span>
  )
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-categories" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">categories</span><span
            class="method-args">(active_only = AboutYou::SDK::Model::Category::ACTIVE_ONLY)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Getter for the categories</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>active_only</code> -&gt; Boolean controlling whether only active
categories should be returned or not</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Array containing instances of <a
href="Category.html">AboutYou::SDK::Model::Category</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="categories-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 389</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">categories</span>(<span class="ruby-identifier">active_only</span> = <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">Category</span><span class="ruby-operator">::</span><span class="ruby-constant">ACTIVE_ONLY</span>)
  <span class="ruby-identifier">root_categories</span>(<span class="ruby-identifier">active_only</span>)
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-category" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">category</span><span
            class="method-args">(active = false)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method is used for getting a category</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>active</code> -&gt; Boolean determining whether the category has to
be active or not</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>nil / instance of <a
href="Category.html">AboutYou::SDK::Model::Category</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="category-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 314</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">category</span>(<span class="ruby-identifier">active</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">category_id_paths</span>

  <span class="ruby-identifier">leaf_categories</span>(<span class="ruby-identifier">active</span>)[<span class="ruby-identifier">leaf_categories</span>(<span class="ruby-identifier">active</span>).<span class="ruby-identifier">keys</span>[<span class="ruby-value">0</span>]]
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-category_with_longest_active_path" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">category_with_longest_active_path</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Getter for the deepest category</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>nil / instance of <a
href="Category.html">AboutYou::SDK::Model::Category</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="category_with_longest_active_path-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 326</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">category_with_longest_active_path</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">category_id_paths</span>

  <span class="ruby-identifier">category_id_paths</span>.<span class="ruby-identifier">sort!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span><span class="ruby-operator">|</span> <span class="ruby-identifier">y</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">count</span> }.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">factory</span>.<span class="ruby-identifier">category_manager</span>.<span class="ruby-identifier">category</span>(<span class="ruby-identifier">path</span>[<span class="ruby-value">-1</span>]) <span class="ruby-keyword">if</span>
    <span class="ruby-identifier">factory</span>.<span class="ruby-identifier">category_manager</span>.<span class="ruby-identifier">category</span>(<span class="ruby-identifier">path</span>[<span class="ruby-value">-1</span>]).<span class="ruby-identifier">path_active?</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-excluded_facet_groups" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">excluded_facet_groups</span><span
            class="method-args">(selected_facet_group_set)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Getter for the excluded groups</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>selected_facet_group_set</code> -&gt; selected instance of <a
href="FacetGroupSet.html">AboutYou::SDK::Model::FacetGroupSet</a></p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Hash containing pairs of unique_group_key =&gt; instance of <a
href="FacetGroup.html">AboutYou::SDK::Model::FacetGroup</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="excluded_facet_groups-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 495</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">excluded_facet_groups</span>(<span class="ruby-identifier">selected_facet_group_set</span>)
  <span class="ruby-identifier">all_groups</span> = {}

  <span class="ruby-identifier">variants</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">variant</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">facet_group_set</span>.<span class="ruby-identifier">contains</span>(<span class="ruby-identifier">selected_facet_group_set</span>)

    <span class="ruby-identifier">facet_group_set</span> = <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">facet_group_set</span>
    <span class="ruby-identifier">facet_group_set</span>.<span class="ruby-identifier">group_ids</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">group_id</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">selected_facet_group_set</span>.<span class="ruby-identifier">group_ids</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">group_id</span>)
      <span class="ruby-identifier">group</span> = <span class="ruby-identifier">facet_group_set</span>.<span class="ruby-identifier">group</span>(<span class="ruby-identifier">group_id</span>)
      <span class="ruby-identifier">fail</span> <span class="ruby-string">'RuntimeException! group for id '</span> <span class="ruby-operator">+</span> <span class="ruby-constant">String</span>(<span class="ruby-identifier">group_id</span>) <span class="ruby-operator">+</span>
        <span class="ruby-string">' not found'</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">group</span>.<span class="ruby-identifier">nil?</span>
      <span class="ruby-identifier">facets</span> = <span class="ruby-identifier">group</span>.<span class="ruby-identifier">facets</span>
      <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">facets</span>

      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">all_groups</span>[<span class="ruby-identifier">group_id</span>]
        <span class="ruby-identifier">all_groups</span>[<span class="ruby-identifier">group_id</span>] = <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">FacetGroup</span>.<span class="ruby-identifier">new</span>(
          <span class="ruby-identifier">group</span>.<span class="ruby-identifier">id</span>,
          <span class="ruby-identifier">group</span>.<span class="ruby-identifier">name</span>
        )
        <span class="ruby-identifier">all_groups</span>[<span class="ruby-identifier">group_id</span>].<span class="ruby-identifier">add_facets</span>(<span class="ruby-identifier">facets</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">all_groups</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-facet_group_set" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">facet_group_set</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Getter for the facet group set</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>instance of <a
href="FacetGroupSet.html">AboutYou::SDK::Model::FacetGroupSet</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="facet_group_set-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 299</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">facet_group_set</span>
  <span class="ruby-identifier">generate_facet_group_set</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@facet_groups</span>

  <span class="ruby-ivar">@facet_groups</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-generate_facet_group_set" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">generate_facet_group_set</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method generates a facet group set for self.facet_ids</p>
<ul><li>
<p><strong>Fails</strong>    :</p>
<ul><li>
<p>if self.facet_ids is empty</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="generate_facet_group_set-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 285</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">generate_facet_group_set</span>
  <span class="ruby-identifier">fail</span> <span class="ruby-string">'RuntimeException! To use this method, you must add the field
    ProductFields::ATTRIBUTES_MERGED to the &quot;product search&quot; or
    &quot;products by ids&quot;'</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">facet_ids</span>.<span class="ruby-identifier">empty?</span>

  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">facet_groups</span> = <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">FacetGroupSet</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">facet_ids</span>)
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-group_facets" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">group_facets</span><span
            class="method-args">(group_id)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Getter for facets for a certain group id</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>group_id</code> -&gt; group_id used for searching</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li><dl class="rdoc-list label-list"><dt>
<dd>
<p>/ instance of <a
href="FacetGroup.html">AboutYou::SDK::Model::FacetGroup</a></p>
</dd></dl>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="group_facets-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 415</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">group_facets</span>(<span class="ruby-identifier">group_id</span>)
  <span class="ruby-identifier">facet_group_set</span>.<span class="ruby-identifier">group</span>(<span class="ruby-identifier">group_id</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">group</span>.<span class="ruby-identifier">facets</span> <span class="ruby-operator">:</span> []
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-leaf_category_ids" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">leaf_category_ids</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Getter for the leaf category ids</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Array containing category_ids</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="leaf_category_ids-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 371</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">leaf_category_ids</span>
  <span class="ruby-identifier">leaf_categories</span> = []
  <span class="ruby-identifier">category_id_paths</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">category_id_path</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">leaf_categories</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">category_id_path</span>[<span class="ruby-value">-1</span>])
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">leaf_categories</span>.<span class="ruby-identifier">uniq</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-parse_attributes_json" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">parse_attributes_json</span><span
            class="method-args">(attributes_json_object)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method is used for parsing an attribues json object</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>attributes_json_object</code> -&gt; the attributes_json_object
received from the api</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>nil / a Hash containing pairs of <a
href="Product.html#attribute-i-facet_ids">#facet_ids</a> =&gt; <a
href="Facet.html">AboutYou::SDK::Model::Facet</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="parse_attributes_json-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 223</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_attributes_json</span>(<span class="ruby-identifier">attributes_json_object</span>)
  <span class="ruby-identifier">ids</span> = {}

  <span class="ruby-identifier">attributes_json_object</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">group</span>, <span class="ruby-identifier">facet_ids</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">gid</span> = <span class="ruby-identifier">group</span>[<span class="ruby-value">11</span><span class="ruby-operator">..</span><span class="ruby-identifier">group</span>.<span class="ruby-identifier">length</span>] <span class="ruby-comment"># rm prefix 'attributes'</span>

    <span class="ruby-comment"># TODO: Remove Workaround for Ticket ???</span>
    <span class="ruby-identifier">facet_ids</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">facet_ids</span>)
    <span class="ruby-identifier">ids</span>[<span class="ruby-identifier">gid</span>] = <span class="ruby-identifier">facet_ids</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">ids</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-parse_category_id_paths" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">parse_category_id_paths</span><span
            class="method-args">(json_object)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method is used for parsing the category id paths for this product</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>json_object</code> -&gt; the json_object received from the api</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Array of Strings</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="parse_category_id_paths-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 169</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_category_id_paths</span>(<span class="ruby-identifier">json_object</span>)
  <span class="ruby-identifier">paths</span> = []

  <span class="ruby-identifier">json_object</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">category_paths</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">index</span>(<span class="ruby-string">'categories'</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
      <span class="ruby-identifier">paths</span> = <span class="ruby-identifier">category_paths</span>
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">paths</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-parse_facet_ids" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">parse_facet_ids</span><span
            class="method-args">(json_object)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method is used for parsing the facet ids of this product</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>json_object</code> -&gt; the json_object received from the api</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>a Hash containing pairs of <a
href="Product.html#attribute-i-facet_ids">#facet_ids</a> =&gt; <a
href="Facet.html">AboutYou::SDK::Model::Facet</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="parse_facet_ids-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 191</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_facet_ids</span>(<span class="ruby-identifier">json_object</span>)
  <span class="ruby-identifier">ids</span> = <span class="ruby-identifier">parse_facet_ids_in_attributes_merged</span>(<span class="ruby-identifier">json_object</span>)
  <span class="ruby-identifier">ids</span> = <span class="ruby-identifier">parse_facet_ids_in_variants</span>(<span class="ruby-identifier">json_object</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">ids</span>.<span class="ruby-identifier">nil?</span>
  <span class="ruby-identifier">ids</span> = <span class="ruby-identifier">parse_facet_ids_in_brand</span>(<span class="ruby-identifier">json_object</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">ids</span>.<span class="ruby-identifier">nil?</span>

  <span class="ruby-operator">!</span><span class="ruby-identifier">ids</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">ids</span> <span class="ruby-operator">:</span> {}
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-parse_facet_ids_in_attributes_merged" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">parse_facet_ids_in_attributes_merged</span><span
            class="method-args">(json_object)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method is used for parsing the facet ids in merged attributes</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>json_object</code> -&gt; the json_object received from the api</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>nil / a Hash containing pairs of <a
href="Product.html#attribute-i-facet_ids">#facet_ids</a> =&gt; <a
href="Facet.html">AboutYou::SDK::Model::Facet</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="parse_facet_ids_in_attributes_merged-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 208</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_facet_ids_in_attributes_merged</span>(<span class="ruby-identifier">json_object</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'attributes_merged'</span>]

  <span class="ruby-identifier">parse_attributes_json</span>(<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'attributes_merged'</span>])
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-parse_facet_ids_in_brand" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">parse_facet_ids_in_brand</span><span
            class="method-args">(json_object)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method is used for parsing the facet ids brands</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>json_object</code> -&gt; the json_object received from the api</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>nil / a Hash containing pairs of <a
href="Product.html#attribute-i-facet_ids">#facet_ids</a> =&gt; <a
href="Facet.html">AboutYou::SDK::Model::Facet</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="parse_facet_ids_in_brand-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 273</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_facet_ids_in_brand</span>(<span class="ruby-identifier">json_object</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'brand_id'</span>]

  { <span class="ruby-string">'0'</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'brand_id'</span>]] }
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-parse_facet_ids_in_variants" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">parse_facet_ids_in_variants</span><span
            class="method-args">(json_object)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method is used for parsing the facet ids in the variants of this
product</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>json_object</code> -&gt; the json_object received from the api</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Array containing facet ids</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="parse_facet_ids_in_variants-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 246</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_facet_ids_in_variants</span>(<span class="ruby-identifier">json_object</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'variants'</span>]
    <span class="ruby-identifier">ids</span> = []
    <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'variants'</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">variant</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">ids</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">parse_attributes_json</span>(<span class="ruby-identifier">variant</span>[<span class="ruby-string">'attributes'</span>]))
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">ids</span> = <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">FacetGroupSet</span>.<span class="ruby-identifier">merge_facet_ids</span>(<span class="ruby-identifier">ids</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">ids</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'default_variant'</span>]
    <span class="ruby-identifier">ids</span> = <span class="ruby-identifier">parse_attributes_json</span>(
      <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'default_variant'</span>][<span class="ruby-string">'attributes'</span>]
    )
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">ids</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-parse_styles" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">parse_styles</span><span
            class="method-args">(json_object, factory)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method is used for parsing the styles of the product</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>json_object</code> -&gt; the json_object received from the api</p>
</li><li>
<p><code>factory</code> -&gt; instance of <a
href="../Factory/DefaultModelFactory.html">AboutYou::SDK::Factory::DefaultModelFactory</a></p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Array containing instances of <a
href="Product.html">AboutYou::SDK::Model::Product</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="parse_styles-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 150</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_styles</span>(<span class="ruby-identifier">json_object</span>, <span class="ruby-identifier">factory</span>)
  <span class="ruby-identifier">styles</span> = []

  <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'styles'</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">style</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">styles</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">factory</span>.<span class="ruby-identifier">create_product</span>(<span class="ruby-identifier">style</span>))
  <span class="ruby-keyword">end</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">json_object</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-string">'styles'</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">json_object</span>[<span class="ruby-string">'styles'</span>].<span class="ruby-identifier">empty?</span>

  <span class="ruby-identifier">styles</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-parse_variants" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">parse_variants</span><span
            class="method-args">(json_object, factory, product, attribute_name = 'variants')</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method is used for parsing the variants of the product</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>json_object</code> -&gt; the json_object received from the api</p>
</li><li>
<p><code>factory</code> -&gt; instance of <a
href="../Factory/DefaultModelFactory.html">AboutYou::SDK::Factory::DefaultModelFactory</a></p>
</li><li>
<p><code>product</code> -&gt; self</p>
</li><li>
<p><code>attribute_name</code> -&gt; attribute name for parsing [optional]</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Hash containing pairs of variant_id =&gt; instance of <a
href="Variant.html">AboutYou::SDK::Model::Variant</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="parse_variants-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 125</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_variants</span>(<span class="ruby-identifier">json_object</span>, <span class="ruby-identifier">factory</span>, <span class="ruby-identifier">product</span>, <span class="ruby-identifier">attribute_name</span> = <span class="ruby-string">'variants'</span>)
  <span class="ruby-identifier">variants</span> = {}

  <span class="ruby-identifier">json_object</span>[<span class="ruby-identifier">attribute_name</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">json_variant</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">variants</span>[<span class="ruby-identifier">json_variant</span>[<span class="ruby-string">'id'</span>]] = <span class="ruby-identifier">factory</span>.<span class="ruby-identifier">create_variant</span>(
      <span class="ruby-identifier">json_variant</span>,
      <span class="ruby-identifier">product</span>
    )
  <span class="ruby-keyword">end</span> <span class="ruby-keyword">if</span>
  <span class="ruby-identifier">json_object</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">attribute_name</span>) <span class="ruby-operator">&amp;&amp;</span>
  <span class="ruby-operator">!</span><span class="ruby-identifier">json_object</span>[<span class="ruby-identifier">attribute_name</span>].<span class="ruby-identifier">empty?</span>

  <span class="ruby-identifier">variants</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-root_category_ids" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">root_category_ids</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Getter for the root category ids</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Array containing category_ids</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="root_category_ids-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 356</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">root_category_ids</span>
  <span class="ruby-identifier">root_category</span> = []
  <span class="ruby-identifier">category_id_paths</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">category_id_path</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">root_category</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">category_id_path</span>[<span class="ruby-value">0</span>])
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">root_category</span>.<span class="ruby-identifier">uniq</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-selectable_facet_groups" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">selectable_facet_groups</span><span
            class="method-args">(selected_facet_group_set)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Getter for the selectable facet groups</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>selected_facet_group_set</code> -&gt; selected instance of <a
href="FacetGroupSet.html">AboutYou::SDK::Model::FacetGroupSet</a></p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Hash containing pairs of unique_group_key =&gt; instance of <a
href="FacetGroup.html">AboutYou::SDK::Model::FacetGroup</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="selectable_facet_groups-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 449</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">selectable_facet_groups</span>(<span class="ruby-identifier">selected_facet_group_set</span>)
  <span class="ruby-identifier">all_groups</span> = {}
  <span class="ruby-identifier">selected_group_ids</span> = <span class="ruby-identifier">selected_facet_group_set</span>.<span class="ruby-identifier">group_ids</span>

  <span class="ruby-identifier">variants</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">variant</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">facet_group_set</span>.<span class="ruby-identifier">contains</span>(<span class="ruby-identifier">selected_facet_group_set</span>)

    <span class="ruby-identifier">facet_group_set</span> = <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">facet_group_set</span>
    <span class="ruby-identifier">ids</span> = <span class="ruby-identifier">facet_group_set</span>.<span class="ruby-identifier">group_ids</span>

    <span class="ruby-identifier">ids</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">group_id</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">selected_group_ids</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">group_id</span>)

      <span class="ruby-identifier">group</span> = <span class="ruby-identifier">facet_group_set</span>.<span class="ruby-identifier">group</span>(<span class="ruby-identifier">group_id</span>)
      <span class="ruby-identifier">fail</span> <span class="ruby-string">'RuntimeException! group for id '</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">group_id</span> <span class="ruby-operator">+</span>
        <span class="ruby-string">' not found'</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">group</span>.<span class="ruby-identifier">nil?</span>

      <span class="ruby-identifier">all_groups</span>[<span class="ruby-identifier">group_id</span>][<span class="ruby-identifier">group</span>.<span class="ruby-identifier">unique_key</span>] = <span class="ruby-identifier">group</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">selected_group_ids</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">group_id</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">ids</span> = <span class="ruby-identifier">selected_facet_group_set</span>.<span class="ruby-identifier">ids</span>
    <span class="ruby-identifier">ids</span>[<span class="ruby-identifier">group_id</span>] = <span class="ruby-keyword">nil</span>
    <span class="ruby-identifier">my_facet_group_set</span> = <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">FacetGroupSet</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ids</span>)
    <span class="ruby-identifier">variants</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">variant</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">facet_group_set</span> = <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">facet_group_set</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">facet_group_set</span>.<span class="ruby-identifier">contains</span>(<span class="ruby-identifier">my_facet_group_set</span>)
        <span class="ruby-identifier">group</span> = <span class="ruby-identifier">facet_group_set</span>.<span class="ruby-identifier">group</span>(<span class="ruby-identifier">group_id</span>)
        <span class="ruby-identifier">all_groups</span>[<span class="ruby-identifier">group_id</span>][<span class="ruby-identifier">group</span>.<span class="ruby-identifier">unique_key</span>] = <span class="ruby-identifier">group</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">all_groups</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-variant_by_facet" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">variant_by_facet</span><span
            class="method-args">(facet_group_set)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method searches for a variant by a certain facet group set</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>facet_group_set</code> -&gt; <a
href="Product.html#method-i-facet_group_set">#facet_group_set</a> used for
searching</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>nil / instance of <a href="Variant.html">AboutYou::SDK::Model::Variant</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="variant_by_facet-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 577</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">variant_by_facet</span>(<span class="ruby-identifier">facet_group_set</span>)
  <span class="ruby-identifier">key</span> = <span class="ruby-identifier">facet_group_set</span>.<span class="ruby-identifier">unique_key</span>
  <span class="ruby-identifier">variants</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">variant</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">variant</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">facet_group_set</span>.<span class="ruby-identifier">unique_key</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">key</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-variant_by_id" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">variant_by_id</span><span
            class="method-args">(variant_id)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method returns a variant by a certain variant_id</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>variant_id</code> -&gt; variant id used for searching</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>nil / instance of <a href="Variant.html">AboutYou::SDK::Model::Variant</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="variant_by_id-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 545</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">variant_by_id</span>(<span class="ruby-identifier">variant_id</span>)
  <span class="ruby-identifier">variants</span>[<span class="ruby-identifier">variant_id</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">variants</span>[<span class="ruby-identifier">variant_id</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-variants_by_ean" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">variants_by_ean</span><span
            class="method-args">(ean)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method searches for variants by a certain ean</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>ean</code> -&gt; ean used for searching</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li><dl class="rdoc-list label-list"><dt>
<dd>
<p>/ Array containing instances of <a
href="Variant.html">AboutYou::SDK::Model::Variant</a></p>
</dd></dl>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="variants_by_ean-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 558</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">variants_by_ean</span>(<span class="ruby-identifier">ean</span>)
  <span class="ruby-identifier">variants</span> = []

  <span class="ruby-identifier">variants</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">_key</span>, <span class="ruby-identifier">variant</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">variants</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">variant</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">ean</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">ean</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">variants</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-variants_by_facet_id" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">variants_by_facet_id</span><span
            class="method-args">(facet_id, group_id)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method searches for variants by a certain facet_id and group_id</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>facet_id</code> -&gt; facet_id used for searching</p>
</li><li>
<p><code>group_id</code> -&gt; group_id used for searching</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li><dl class="rdoc-list label-list"><dt>
<dd>
<p>/ Array containing instances of <a
href="Variant.html">AboutYou::SDK::Model::Variant</a></p>
</dd></dl>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="variants_by_facet_id-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/product.rb, line 596</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">variants_by_facet_id</span>(<span class="ruby-identifier">facet_id</span>, <span class="ruby-identifier">group_id</span>)
  <span class="ruby-identifier">variants</span> = []

  <span class="ruby-identifier">facet</span> = <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Facet</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">facet_id</span>, <span class="ruby-string">''</span>, <span class="ruby-string">''</span>, <span class="ruby-identifier">group_id</span>, <span class="ruby-string">''</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">variants</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">variant</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">variants</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">variant</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">facet_group_set</span>.<span class="ruby-identifier">contains</span>(<span class="ruby-identifier">facet</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">variants</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
    </section>
  
  </section>
</main>


<footer id="validator-badges" role="contentinfo">
  <p><a href="http://validator.w3.org/check/referer">Validate</a>
  <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.2.
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>

